class Solution {
public:
    vector<vector<int>> findWinners(vector<vector<int>>& nums)
    {
        unordered_map<int, int> hash;
        for (int i = 0; i < nums.size(); i++)
            hash[nums[i][0]] = 0;
        for (int i = 0; i < nums.size(); i++)
            hash[nums[i][1]]++;
        vector<int> ans1;
        vector<int> ans2;
        for (auto& a : hash)
        {
            if (a.second == 0)
                ans1.push_back(a.first);
            if (a.second == 1)
                ans2.push_back(a.first);
        }
        sort(ans1.begin(), ans1.end());
        sort(ans2.begin(), ans2.end());

        return { ans1,ans2 };
    }
};